<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

<div id="app">
  <h2>总价格:{{totalPrice}}</h2>
</div>

<script src="../js/vue%20.js"></script>
<script>
  //let(变量)/const(常量)
  //声明式编程
  const app = new Vue({
    el: "#app",
    data: {
      //定义数据
      books: [
        {id: 110, name: 'linux', price: 119},
        {id: 111, name: '代码大全', price: 105},
        {id: 112, name: '深入理解计算机原理', price: 98},
      ]
    },
    computed: {
      totalPrice: function () {
        let result = 0
        for(let i=0; i< this.books.length; i++){
          result += this.books[i].price
        }
        return result
      }
    }
  })
</script>
</body>
</html>